﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace ShevaEngine.Core.Modules.Graphics
{
    /// <summary>
    /// To store instance transform matrices in a vertex buffer, we use this custom
    /// vertex type which encodes 4x4 matrices as a set of four Vector4 values.
    /// </summary>
    public class InstanceVertexDeclaration : VertexDeclaration
    {
        /// <summary>Blendweight declaration.</summary>
        public static readonly InstanceVertexDeclaration BlendWeight = new InstanceVertexDeclaration(
            new VertexElement[] {
                new VertexElement(0,  VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 0),
                new VertexElement(16, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 1),
                new VertexElement(32, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 2),
                new VertexElement(48, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 3),            
            });

        /// <summary>Blendweight declaration.</summary>
        public static readonly InstanceVertexDeclaration Colors = new InstanceVertexDeclaration(
            new VertexElement[] {
                new VertexElement(0,  VertexElementFormat.Vector4, VertexElementUsage.Color, 0),
                new VertexElement(16, VertexElementFormat.Vector4, VertexElementUsage.Color, 1),
                new VertexElement(32, VertexElementFormat.Vector4, VertexElementUsage.Color, 2),
                new VertexElement(48, VertexElementFormat.Vector4, VertexElementUsage.Color, 3),            
            });

        /// <summary>
        /// Constructor.
        /// </summary>
        public InstanceVertexDeclaration(params VertexElement[] elements)
            : base(elements)
        {
        }
    }
}
